import guide from './guide.json';
import component from './component.json';

type Item = {
  text: string;
  children?: Item[];
  link?: string;
};

const mapPrefix = (item: Item, prefix = ''): Item => {
  if (item.children && item.children.length > 0) {
    return {
      ...item,
      children: item.children.map((child) => mapPrefix(child, prefix)),
    };
  }
  return {
    ...item,
    link: `${prefix}${item.link}`,
  };
};

const getSidebars = () => {
  return {
    '/guide/': guide,
    '/component/': component,
  };
};

export const sidebars = getSidebars();
